#include "MeshList.h"
#include "ObjMesh.h"
#include "DAEFloat3.h"

MeshList::MeshList(void)
{
}

MeshList::~MeshList(void)
{
	vector<ObjMesh*>::const_iterator it;
	for (it=m_Meshes.begin();
		it!= m_Meshes.end();
		it++)
	{
		delete (*it);
	}
}

void MeshList::AddMesh(ObjMesh* mesh)
{
	m_Meshes.push_back(mesh);
	m_MeshMap[mesh->GetName()]=mesh;
}

ObjMesh* MeshList::GetSubObject(const tstring& name)const
{
	map<tstring,ObjMesh*>::const_iterator it = m_MeshMap.find(name);
	if ( it != m_MeshMap.end())
		return (*it).second;
	else
		return NULL;
}

ObjMesh* MeshList::GetFirstMesh() const
{
	if ( m_Meshes.size() > 0 )
		return m_Meshes[0];
	else
		return NULL;
}